package aoj.no_0500;

import java.util.Scanner;

public class No_0500 {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(true) {
			int nCard = sc.nextInt();
			if(nCard == 0)
				break;
			
			int aScore = 0;
			int bScore = 0;
			
			int count = 0;
			while(count < nCard) {
				int a = sc.nextInt();
				int b = sc.nextInt();
				if(a > b)
					aScore += a + b;
				else if(a == b) {
					aScore += a;
					bScore += b;
				}
				else {
					bScore += a + b;
				}
				count++;
			}
			System.out.printf("%d %d\n", aScore, bScore);
		}
	}
}
/*
3
9 1
5 4
0 8
3
9 1
5 4
1 0
3
9 1
5 5
1 8
0 
*/
